<?php

require_once "BaseService.php";

/**
 * @author Virtualidad
 * @version 1.0
 * @created 01-abr-2011 04:23:31 p.m.
 */
class FormulariosService extends BaseService {

    /**
     *
     * @param formId
     */
    function GetById($formId) {

        Loader::using("models::entities::TiposFormularios");
        $response = parent::invokeService("GetById", $formId);
        $result = parent::processSingleObjectResponse($response, parent::getMimeType(), "TiposFormularios", TiposFormularios::MAPPING());
        return $result;
    }

    function SaveForm(Suscritos $form) {
        $Valor = $form->getRespuestas();
        $form->setRespuestas(null);
        $serializer = parent::getSerializer(parent::getMimeType());
        $formulario = $serializer->serialize($form);
        $valores = $serializer->serializeArray($Valor);
        
        $data = $serializer->wrapArray(array(
                    "Formulario" => $formulario,
                    "Valores" => $valores,
                ));
        
        $response = parent::invokeService("SaveForm", $data);

        return $response;
    }
    
    function GetByFormulario($idFormulario) {
        Loader::using("models::entities::Suscritos");
        $response = parent::invokeService("GetByFormulario", $idFormulario);
        $result = parent::processArrayResponse($response, parent::getMimeType(), "Suscritos", Suscritos::MAPPING());
        
        return $result;
    }

    public function getServiceClass() {
        return "Formularios";
    }

}

?>